.class public Lcom/waiqin365/lightapp/view/EditTextHasClear;
.super Landroid/widget/EditText;

# interfaces
.implements Ljava/util/Observer;


# instance fields
.field a:Landroid/view/inputmethod/InputMethodManager;

.field private b:Landroid/graphics/drawable/Drawable;

.field private c:Landroid/graphics/Rect;

.field private d:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 2

    invoke-direct {p0, p1}, Landroid/widget/EditText;-><init>(Landroid/content/Context;)V

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->d:Z

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getContext()Landroid/content/Context;

    move-result-object v0

    const-string/jumbo v1, "input_method"

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/inputmethod/InputMethodManager;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->a:Landroid/view/inputmethod/InputMethodManager;

    invoke-direct {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->a()V

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 2

    invoke-direct {p0, p1, p2}, Landroid/widget/EditText;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->d:Z

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getContext()Landroid/content/Context;

    move-result-object v0

    const-string/jumbo v1, "input_method"

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/inputmethod/InputMethodManager;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->a:Landroid/view/inputmethod/InputMethodManager;

    invoke-direct {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->a()V

    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .locals 2

    invoke-direct {p0, p1, p2, p3}, Landroid/widget/EditText;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->d:Z

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getContext()Landroid/content/Context;

    move-result-object v0

    const-string/jumbo v1, "input_method"

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/inputmethod/InputMethodManager;

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->a:Landroid/view/inputmethod/InputMethodManager;

    invoke-direct {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->a()V

    return-void
.end method

.method private a()V
    .locals 4

    const/4 v3, 0x0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getCompoundDrawables()[Landroid/graphics/drawable/Drawable;

    move-result-object v0

    const/4 v1, 0x2

    aget-object v0, v0, v1

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    if-nez v0, :cond_0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const v1, 0x7f02016c

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    :cond_0
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    iget-object v1, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v1}, Landroid/graphics/drawable/Drawable;->getIntrinsicWidth()I

    move-result v1

    iget-object v2, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v2}, Landroid/graphics/drawable/Drawable;->getIntrinsicHeight()I

    move-result v2

    invoke-virtual {v0, v3, v3, v1, v2}, Landroid/graphics/drawable/Drawable;->setBounds(IIII)V

    invoke-direct {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b()V

    new-instance v0, Lcom/waiqin365/lightapp/view/ed;

    invoke-direct {v0, p0}, Lcom/waiqin365/lightapp/view/ed;-><init>(Lcom/waiqin365/lightapp/view/EditTextHasClear;)V

    invoke-virtual {p0, v0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->addTextChangedListener(Landroid/text/TextWatcher;)V

    return-void
.end method

.method static synthetic a(Lcom/waiqin365/lightapp/view/EditTextHasClear;)V
    .locals 0

    invoke-direct {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b()V

    return-void
.end method

.method private b()V
    .locals 2

    const/4 v1, 0x0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getText()Landroid/text/Editable;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v0

    if-eqz v0, :cond_0

    iget-boolean v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->d:Z

    if-eqz v0, :cond_0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->hasFocus()Z

    move-result v0

    if-nez v0, :cond_1

    :cond_0
    invoke-virtual {p0, v1, v1, v1, v1}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->setCompoundDrawables(Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;)V

    :goto_0
    return-void

    :cond_1
    iget-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {p0, v1, v1, v0, v1}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->setCompoundDrawables(Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;)V

    goto :goto_0
.end method


# virtual methods
.method protected onAttachedToWindow()V
    .locals 1

    invoke-static {}, Lcom/waiqin365/lightapp/view/ef;->a()Lcom/waiqin365/lightapp/view/ef;

    move-result-object v0

    invoke-virtual {v0, p0}, Lcom/waiqin365/lightapp/view/ef;->addObserver(Ljava/util/Observer;)V

    invoke-super {p0}, Landroid/widget/EditText;->onAttachedToWindow()V

    return-void
.end method

.method protected onDetachedFromWindow()V
    .locals 1

    invoke-static {}, Lcom/waiqin365/lightapp/view/ef;->a()Lcom/waiqin365/lightapp/view/ef;

    move-result-object v0

    invoke-virtual {v0, p0}, Lcom/waiqin365/lightapp/view/ef;->deleteObserver(Ljava/util/Observer;)V

    invoke-super {p0}, Landroid/widget/EditText;->onDetachedFromWindow()V

    return-void
.end method

.method protected onFocusChanged(ZILandroid/graphics/Rect;)V
    .locals 1

    invoke-super {p0, p1, p2, p3}, Landroid/widget/EditText;->onFocusChanged(ZILandroid/graphics/Rect;)V

    if-eqz p1, :cond_0

    const/4 v0, 0x0

    invoke-virtual {p0, v0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->setCursorVisible(Z)V

    const/4 v0, 0x1

    invoke-virtual {p0, v0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->setCursorVisible(Z)V

    :cond_0
    return-void
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .locals 4

    const/4 v3, 0x1

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    if-eqz v0, :cond_0

    iget-boolean v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->d:Z

    if-eqz v0, :cond_0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getCompoundDrawables()[Landroid/graphics/drawable/Drawable;

    move-result-object v0

    const/4 v1, 0x2

    aget-object v0, v0, v1

    if-eqz v0, :cond_0

    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v0

    if-ne v0, v3, :cond_0

    iget-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v0}, Landroid/graphics/drawable/Drawable;->getBounds()Landroid/graphics/Rect;

    move-result-object v0

    iput-object v0, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->c:Landroid/graphics/Rect;

    invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F

    move-result v0

    float-to-int v0, v0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->getWidth()I

    move-result v1

    iget-object v2, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->c:Landroid/graphics/Rect;

    invoke-virtual {v2}, Landroid/graphics/Rect;->width()I

    move-result v2

    sub-int/2addr v1, v2

    if-le v0, v1, :cond_0

    invoke-virtual {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->requestFocus()Z

    const-string/jumbo v0, ""

    invoke-virtual {p0, v0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->setText(Ljava/lang/CharSequence;)V

    const/4 v0, 0x3

    invoke-virtual {p1, v0}, Landroid/view/MotionEvent;->setAction(I)V

    :cond_0
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v0

    if-ne v0, v3, :cond_1

    new-instance v0, Landroid/os/Handler;

    invoke-direct {v0}, Landroid/os/Handler;-><init>()V

    new-instance v1, Lcom/waiqin365/lightapp/view/ee;

    invoke-direct {v1, p0}, Lcom/waiqin365/lightapp/view/ee;-><init>(Lcom/waiqin365/lightapp/view/EditTextHasClear;)V

    const-wide/16 v2, 0xa

    invoke-virtual {v0, v1, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

    :cond_1
    invoke-super {p0, p1}, Landroid/widget/EditText;->onTouchEvent(Landroid/view/MotionEvent;)Z

    move-result v0

    return v0
.end method

.method public setShowClear(Z)V
    .locals 0

    iput-boolean p1, p0, Lcom/waiqin365/lightapp/view/EditTextHasClear;->d:Z

    return-void
.end method

.method public update(Ljava/util/Observable;Ljava/lang/Object;)V
    .locals 0

    invoke-direct {p0}, Lcom/waiqin365/lightapp/view/EditTextHasClear;->b()V

    return-void
.end method
